package modelTest.view.view2D;

import java.awt.Font;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import javax.imageio.ImageIO;

import modelTest.view.fonts.MyFont;

public class Assets{
	
	private static final  Assets assetsLoader = new Assets();
	
	public static final int SHIP_2D = 0;
	public static final int BULLET_AVIABLE_INDICATOR = 1;
	public static final int GALAXY_BG = 2;
	public static final int MOB_2D = 3;
	
	public static final int FONT_SCORE = 0;
	
	private ArrayList<File> files = new ArrayList<File>();
	private ArrayList<BufferedImage> assets = new ArrayList<BufferedImage>();
	private ArrayList<MyFont> fonts = new ArrayList<MyFont>();
	
	
	private Assets() {
		initFiles();
		loadFonts();
		loadAssets();
	}
	
	public static Assets getsLoader(){
		return assetsLoader;
	}
	
	private void initFiles(){
		files.add( SHIP_2D , new File("Assets/Ship/ship2DTest01.png") );
		files.add( BULLET_AVIABLE_INDICATOR, new File("Assets/Ship/BulletIndicatorTest01.png") );
		files.add( GALAXY_BG , new File("Assets/Background/Galaxy01.jpg") );
		files.add( MOB_2D, new File("Assets/Mobs/Mob2DTest01.png") );
	}
	
	private void loadFonts(){
		fonts.add(FONT_SCORE, new MyFont("Assets/Fonts/digiffiti.ttf"));
	}
	
	private void loadAssets(){
		BufferedImage loadedAsset = null ;
		for (File imgFile : files) {
			try {
				loadedAsset = ImageIO.read(imgFile);
				assets.add(loadedAsset);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public BufferedImage getAsset(int asset) {
		return assets.get(asset);
	}
	
	public Font getFont( int fontID, float size ){
		return fonts.get(fontID).getSizedFont(size);
	}

}
